package adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import bean.OrderListBean;
import student.andlei.com.student.R;
import utils.ImageLoaderUtils;

/**
 * author : ChenHuiMing
 * date : 2018/9/15
 * email : 907399255@qq.com
 * description : 答问模块左边适配器
 */
public class OrderAdapter extends BaseQuickAdapter<OrderListBean.ListBean, BaseViewHolder> {
    public OrderAdapter(int layoutResId, @Nullable List<OrderListBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderListBean.ListBean item) {
        ImageView imageView = helper.getView(R.id.iv_logo);
        ImageLoaderUtils.loadImage(mContext, item.schedule_image, imageView);
        helper.setText(R.id.tv_time, item.create_time).setText(R.id.tv_status, getOrderStatus(item.pay_status))
                .setText(R.id.tv_title, item.schedule_name).setText(R.id.tv_teacher, "主讲：" + item.teacher_name)
                .setText(R.id.tv_price, "￥" + item.price).setVisible(R.id.tv_pay, item.pay_status == 10)
                .setVisible(R.id.tv_pay_price, item.pay_status == 100)
                .setText(R.id.tv_pay_price, "实付：" + item.price);
    }

    private String getOrderStatus(int status) {
        if (status == 0) {
            return "取消";
        } else if (status == 10) {
            return "待付款";
        } else if (status == 100) {
            return "已付款";
        }
        return "";
    }
}
